import { defineStore } from 'pinia'
import { ref } from 'vue'
import { postLoginApi } from '@/api/user'

export const useUserStore = defineStore(
  'user',
  () => {
    const userInfo: any = ref({})
    const getInfo = async (data: Object) => {
      const res = await postLoginApi(data)
      userInfo.value = res.data
    }
    const clearUserInfo = () => {
      userInfo.value = {}
    }
    return {
      userInfo,
      getInfo,
      clearUserInfo,
    }
  },
  {
    persist: true,
  },
)
